#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    timer =new QTimer;
    connect(timer,&QTimer::timeout,this,&MainWindow::timeOutslot);

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_startButton_clicked()
{
    timer->start(1000);
}
void MainWindow::timeOutslot()
{
    QString path("E:\\Qt\\WorkPace\\obectTimer\\picture\\");
    path += QString::number(picID);
    path += ".jpg";

    QImage image;
    image.load(path);
    ui->label->setPixmap(QPixmap::fromImage(image));
    picID++;
    if(picID>6) picID=1;


}


void MainWindow::on_sotpButton_clicked()
{
    timer->stop();
}


void MainWindow::on_pushButton_clicked()
{
    QTimer::singleShot(500,this,&MainWindow::timeOutslot);//500毫秒后执行timeOutslot
}

